<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>企业网站管理系统</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/pintuer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css">
    <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
    <script src="${pageContext.request.contextPath}/js/pintuer.js"></script>
    <script type="text/javascript">
        $(function () {
            $('.checkall').change(function(){
                $('.check,.checkall').prop('checked',$(this).prop('checked'));
            })
            $('.check').change(function(){
                if($('.check:checked').length==$('.check').length){
                    $('.checkall').prop('checked',true);
                }else{
                    $('.checkall').prop('checked',false);
                }
            })
        })
        $(function(){
            // 删除选中的商品
            $('.delcheck').click(function(){
                $('.check:checked').parents('.info_item').remove();
            })
        })
        function deleteManager(id){
            if(confirm("您确定要删除吗?")){
                var arr=new Array();
                $("input:checkbox[class='check']:checked").each(function () {
                    arr.push($(this).val());
                });

                arrType=arr.join(',');//把复选框的值以数组形式存放
                $.ajax({
                    url: "${pageContext.request.contextPath}/deleltInfoByListId/"+arrType,
                    // data: {
                    //     //deviceId : [1,2,3,4]
                    //     : ,
                    // },
                    type: "GET",
                    success: function(data) {
                        alert("批量删除成功！")
                    },
                    error: function(err) {
                        alert("批量删除失败！")
                    }
                })
            }

        }


    </script>
</head>
<body>
<div class="panel admin-panel">
    <form action="" method="post">
        <table class="table table-hover text-center">
            <tr>
                <th width="30%"><input type="button" value="全选" class="checkall"/> </th>
                <th width="40%">新闻标题</th>
                <th width="30%">修改</th>
            </tr>
            <c:forEach items="${requestScope.listInfo}" var="a" varStatus="status" >
                <tr class="info_item">
                    <td><input type="checkbox" class="check" value="${a.info_id}"/></td>
                    <td>${a.title }</td>
                    <td>
                        <a class="button border-main" href="${pageContext.request.contextPath}/findInfoById?info_id=${a.info_id}"><span class="icon-edit"></span> 修改</a>
                    </div></td>
                </tr>
            </c:forEach>
            <tr>
                <td colspan="8"><div class="pagelist">
                    <a href="${pageContext.request.contextPath}/findInfoPageAll?page=${requestScope.pageIndex}">首页</a>
                    <c:choose>
                        <c:when test="${pageInfo.pageNum>1}">
                            <a href="${pageContext.request.contextPath}/findInfoPageAll?page=${requestScope.pageInfo.prePage}">上一页</a>
                        </c:when>
                        <c:otherwise>
                            <a>上一页</a>
                        </c:otherwise>
                    </c:choose>
                    <c:forEach begin="1" var="pageNum" end="${pageInfo.pages}">
                        <a href="${pageContext.request.contextPath}/findInfoPageAll?page=${pageNum}">${pageNum}</a>
                    </c:forEach>
                    <c:choose>
                        <c:when test="${pageInfo.pageNum<pageInfo.pages}">
                            <a href="${pageContext.request.contextPath}/findInfoPageAll?page=${requestScope.pageInfo.nextPage}">下一页</a>
                        </c:when>
                        <c:otherwise>
                            <a>下一页</a>
                        </c:otherwise>
                    </c:choose>
                    <a href="${pageContext.request.contextPath}/findInfoPageAll?page=${requestScope.pageInfo.pages}">尾页</a> </div>
                </td>
            </tr>
        </table>
        <input type="submit" value="删除" class="delcheck" onclick="return deleteManager()"/>
    </form>

</div>
</body>
</html>
